<%--
  Created by IntelliJ IDEA.
  User: j
  Date: 2021/11/24
  Time: 10:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="static/bootstrap4/css/bootstrap.css">
    <script src="static/js/jquery-3.2.1.js"></script>
    <script src="static/bootstrap-treeview/js/bootstrap-treeview.js"></script>
    <script src="static/bootstrap4/js/bootstrap.js"></script>
    <title>Title</title>

</head>
<body>
    <form action="./register" method="post">
       用户工号:<input name="userNum"><span id="sp_userNum" style="color: red"></span> <br>
       用户姓名:<input name="userName"><span id="sp_userName" style="color: red"></span><br>
       用户密码:<input name="userPwd"><span id="sp_userPwd" style="color: red"></span><br>
       性别:
        <select name="userGender">
            <option value="M">男</option>
            <option value="W">女</option>
        </select><span id="sp_userGender" style="color: red"></span>
        <br>
        <input type="button" value="注册" onclick="tj()">
    </form>

<script>
    function yz(){
     var  userNum=  $("[name='userNum']").val();
     if (userNum.trim()==""){
         $("#sp_userNum").text("工号不能为空");
     }else {
         if (/[\u4e00-\u9fa5]/g.test(userNum)){
             $("#sp_userNum").text("工号不能为汉字");
         }
     }

        var  userName=  $("[name='userName']").val();

        if (userName.trim()==""){
            $("#sp_userName").text("姓名不能为空");
        }

        var  userPwd=  $("[name='userPwd']").val();
        if (userPwd.trim()==""){
            $("#sp_userPwd").text("密码不能为空");
        }

    }
    function tj(){
        $("span").text("");
        yz();
        if (!$("span").text().empty()){
            $("form").submit();
        }
    }
</script>
</body>
</html>
